#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define M	4
#define N	5

int main(void)
{
	int arr[M][N];
	int i, j, m;
	int t;

	srand(time(NULL));

	for (i = 0; i < M; i++) {
		for (j = 0; j < N; j++) {
			arr[i][j] = rand() % 100;
			printf("%d ", arr[i][j]);
		}
		printf("\n");
	}

	// 每一行从小到大排序
	for (m = 0; m < M; m ++) {
		// 每个数组排序	
		for (i = 0; i < N - 1; i++) {
			for (j = 0; j < N - i - 1; j++)	 {
				if (arr[m][j] > arr[m][j+1]) {
					t = arr[m][j];
					arr[m][j] = arr[m][j+1];
					arr[m][j+1] = t;
				}
			}
		}
	}
	// 遍历
	for (i = 0; i < M; i++) {
		for (j = 0; j < N; j++) {
			printf("%d ", arr[i][j]);
		}
		printf("\n");
	}

	return 0;
}

